<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<title>欢迎页面</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/layout.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/css/common.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/management/css/update.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/common/javascript/plugins/boxy/boxy.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/jquery.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/boxy/jquery.boxy.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/common/javascript/plugins/jquery.extcloudSlideMenu.js"></script>
<%@include file="/WEB-INF/view/commonJavascriptVar.jsp"%>
<script type="text/javascript">
$(function() {
	$("li.layout_search_pull_ss a").extcloudSlideMenu({
		init_hideMenu: true ,
		speed: "fast"
	}) ;
});

function deleteItem(equipmentId,categoryId,aElement) {
	var callback = function(){
		$(aElement).parent().remove();
	};
	ajaxDelete(equipmentId,categoryId,callback) ;
}

function addItem(categoryId,categoryDesc) {
	var equipmentId = '${equipment.equipmentId}';
	var callback = function(){
		$("#categoriesDiv").append("<div>" + categoryDesc + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0);' onclick=javascript:deleteItem('"+equipmentId+"','"+categoryId+"',this)>删除</a></div>"); 
	};
	ajaxAdd(equipmentId,categoryId,callback) ;
}

function ajaxAdd(equipmentId,categoryId,callback) {
	var ajaxParams = {ss:Math.random*100000} ;
	var url = context + "/management/cte/ajaxadd/"+categoryId+"_" + equipmentId ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}

function ajaxDelete(equipmentId,categoryId,callback) {
	var ajaxParams = {ss:Math.random*100000} ;
	var url = context + "/management/mmc/ajaxdelete/"+categoryId+"_" + equipmentId ;
	$.get(url, ajaxParams,
			function(data, textStatus, jqXHR) {
				if (textStatus == "success") {
					if(data.error) {
						alert(data.info) ;
						return false;
					} else if(data.success) {
						callback();
						alert(data.info) ;
						return true ;
					} else {
						alert("出现未知异常.") ;
						return false ;
					}
				}
	}, "json");
}
</script>
<script type="text/javascript">
function add() {
	var boxy = Boxy.load(context+'/management/search/category/presearchforequipmentupdate',{unloadOnHide:true,title:'增加事项与分类对应关系'});
}
</script>
</head>
<body>
<div id="layoutAll">
<table cellpadding="0" cellspacing="0" width="100%" id="layout_content">
	<tr>
		<td height="100" valign="top">
		<div id="layout_title">
		<h4>物品修改</h4>
		</div>
		<div id="layout_search">
		<p>&nbsp;</p>
		</div>
		<div id="layout_search_pull">
		<ul>
			<li><a id="backSubmit" href="#"
				onclick="if(confirm('确定修改?')){$('#backForm').submit();}">确定修改</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" />
			</li>
			<li><a id="backSubmit"
				href="${pageContext.request.contextPath}/management/equipment/index">取消并返回列表</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			<li><a id="backSubmit" href="javascript:void(0);"
				onclick="javascript:add();">增加到分类</a></li>
			<li><img
				src="${pageContext.request.contextPath}/common/images/menufg.jpg" /></li>
			<li class="layout_search_pull_ss"><a href="#"><img
				src="${pageContext.request.contextPath}/common/images/menu_up.gif" /></a></li>
		</ul>
		</div>
		</td>
	</tr>
	<tr>
		<td valign="top">
		<div id="layout_content_body">
		<h1 align="center">物品修改</h1>
		<center>
		<form id="backForm"
			action="${pageContext.request.contextPath}/management/equipment/update/${equipment.equipmentId}"
			method="post">
		<table align="center" width="90%" border="1px" bordercolor="#D4D4D4"
			cellspacing="0px">
			<tr>
				<td width=100><label for="equipmentName">物品名称</label></td>
				<td><input name="equipmentName" type="text"
					value="${equipment.equipmentName}" /></td>
			</tr>
			<tr>
				<td width><label for="equipmentDescription">物品描述</label></td>
				<td><input name="equipmentDescription" type="text"
					value="${equipment.equipmentDescription}" /></td>
			</tr>
			<tr>
				<td width><label for="equipmentItemLevel">物品级别</label></td>
				<td><input name="equipmentItemLevel" type="text"
					value="${equipment.equipmentItemLevel}" /></td>
			</tr>
			<tr>
				<td><label for="equipmentKeywords">关键字</label></td>
				<td><input id="equipmentKeywords" name="equipmentKeywords"
					value="${equipment.equipmentKeywords}" /></td>
			</tr>
			<tr>
				<td>分类信息</td>
				<td>
				<div id="categoriesDiv"><c:forEach
					items="${superCategoryChains}" var="superCategoryChain">
					<div><c:forEach items="${superCategoryChain}"
						var="tempCategory" varStatus="index">
						${tempCategory.categoryName}
						<c:choose>
							<c:when test="${index.index != fn:length(superCategoryChain)-1}">
								&gt;
							</c:when>
							<c:otherwise>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
									href="javascript:void(0);"
									onclick="javascript:deleteItem('${equipment.equipmentId}','${tempCategory.categoryId}',this);">删除</a>
							</c:otherwise>
						</c:choose>
					</c:forEach>&nbsp;&nbsp;&nbsp;&nbsp;</div>
				</c:forEach></div>
				<a href="javascript:void(0);"
					onclick="javascript:add('${equipment.equipmentId}',$('#categoriesDiv'));">增加条目</a>
				</td>
			</tr>
		</table>
		</form>
		</center>
		</div>
		</td>
	</tr>
</table>
</div>
</body>
</html>